﻿using System.Diagnostics;

namespace LFSRecord2.Model.UserActions
{
    public class UserActionAddLayer : UserActionBase
    {
        // Action description, so we can replay this action (and reverse it)
        public CompLayerTypes LayerType { get; set; }
        public int LayerIndex { get; set; }
        public string LayerName { get; set; }

        public UserActionAddLayer()
        {
            Action = UserActionTypes.AddLayer;
        }

        public override void DoUndo()
        {
            Debug.WriteLine("Undoing a AddLayer action");
            if (LayerType == CompLayerTypes.Audio)
                LfsRecordController.project.DeleteLayer(LfsRecordController.project.AudioLayers[LayerIndex]);
            else
                LfsRecordController.project.DeleteLayer(LfsRecordController.project.Layers[LayerIndex]);
        }

        public override void DoRedo()
        {
            Debug.WriteLine("Redoing a AddLayer action");
            switch (LayerType)
            {
                case CompLayerTypes.LookCamera:
                    LfsRecordController.project.AddLookCamera(LayerName);
                    break;
                case CompLayerTypes.FreeCamera:
                    LfsRecordController.project.AddFreeCamera(LayerName);
                    break;
                case CompLayerTypes.Null:
                    LfsRecordController.project.AddNull(LayerName);
                    break;
                case CompLayerTypes.ReplayControl:
                    LfsRecordController.project.AddReplayControl(LayerName);
                    break;
                case CompLayerTypes.ReplayData:
                    LfsRecordController.project.AddReplayData(LayerName);
                    break;
                case CompLayerTypes.Audio:
                    LfsRecordController.project.AddAudio(LayerName);
                    break;
            }
        }
    }
}
